﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace DiscoveryLogic.DataViz.NetworkDiagram.Layouts
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="img"></param>
    public delegate void OnGraphUpdated(Image img);
    /// <summary>
    /// 
    /// </summary>
    public delegate void OnGraphLayoutFinished();

    /// <summary>
    /// 
    /// </summary>
    public interface IGraphLayout
    {
        #region events
        /// <summary>
        /// 
        /// </summary>
        event OnGraphUpdated GraphUpdated;
        /// <summary>
        /// 
        /// </summary>
        event OnGraphLayoutFinished GraphLayoutFinished;
        #endregion

        #region properties
        /// <summary>
        /// 
        /// </summary>
        GraphLayoutAlgorithm LayoutAlgorithm { get; set; }
        /// <summary>
        /// 
        /// </summary>
        int MaxIteration { get; set; }
        /// <summary>
        /// 
        /// </summary>
        SizeF GraphSize { get; set; }
        /// <summary>
        /// 
        /// </summary>
        Color BackgroundColor { get; set; }
        /// <summary>
        /// 
        /// </summary>
        Dictionary<Guid, Vertice> Vertices { get; set; }
        /// <summary>
        /// 
        /// </summary>
        Dictionary<Guid, Edge> Edges { get; set; }
        /// <summary>
        /// 
        /// </summary>
        bool ShowVerticeLabels { get; set; }
        /// <summary>
        /// 
        /// </summary>
        bool ShowEdgeDistances { get; set; }
        /// <summary>
        /// 
        /// </summary>
        double DistanceThreshold { get; set; }
        /// <summary>
        /// 
        /// </summary>
        int DistancePercentileCutoff { get; set; }

        /// <summary>
        /// 
        /// </summary>
        bool IsStopped { get; }

        /// <summary>
        /// rendered image
        /// </summary>
        Image Diagram { get; }

        /// <summary>
        /// 
        /// </summary>
        List<Vertice> SelectedVertices { get; }

        /// <summary>
        /// 
        /// </summary>
        List<Edge> SelectedEdges { get; }
        #endregion

        /// <summary>
        /// 
        /// </summary>
        /// <param name="graphSize"></param>
        /// <param name="g"></param>
        void Init(SizeF graphSize, Graph g);

        /// <summary>
        /// 
        /// </summary>
        void StartRender(bool asyncMode);

        /// <summary>
        /// 
        /// </summary>
        void StopRender();

        /// <summary>
        /// 
        /// </summary>
        void UpdateImage();

        /// <summary>
        /// 
        /// </summary>
        void ContinueLayout();

        #region user interactions
        /// <summary>
        /// vertice got hightlight color (Darker or Lighter dependent on background color)
        /// label is displayed in bold font
        /// </summary>
        /// <param name="mousePos"></param>
        /// <returns></returns>
        Vertice SelectVertice(PointF mousePos);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="v"></param>
        /// <param name="mousePos"></param>
        void DragVertice(Vertice v, PointF mousePos);

        /// <summary>
        /// clear any selected vertices or edges
        /// </summary>
        void UnSelect();

        /// <summary>
        /// when edge is selected, both edge and its connected vertices got highlighted
        /// and label is displayed in bold font 
        /// </summary>
        /// <param name="mousePos"></param>
        /// <returns></returns>
        Edge SelectEdge(PointF mousePos);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="regionOfInterest"></param>
        void Select(RectangleF regionOfInterest);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="vIDs"></param>
        void SelectVertices(List<Guid> vIDs);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="eIDs"></param>
        void SelectEdges(List<Guid> eIDs);
        #endregion
    }
}
